<template>
  <ArmyPanelLayout class="StrangerComp" title="陌生人识别">
    <BtnGroupDevideTab style="margin: 8px 0 8px 21px;" :tabList="tabList" :tabActive="tabActive" @change="typeChangeAction"></BtnGroupDevideTab>
    <template v-slot:subtitle>
      <div class="StrangerComp--subtitle">
        今日进出数（{{total}}次)
      </div>
    </template>
    <div class="StrangerComp--list" v-if="tableData.length">
      <el-scrollbar height="240px">
        <div class="personPanelList">
          <div class="personPanel" v-for="(item, index) in tableData" :key="index">
            <div class="personPanel--img">
              <el-image
                style="width: 100%;max-height: 48px;height: 78px;object-fit: contain;"
                :src="item.picUrl"
                :zoom-rate="1.2"
                :max-scale="7"
                :min-scale="0.2"
                :preview-src-list="[item.picUrl]"
                :initial-index="0"
                fit="none"
                :crossorigin="null"
              >
                <template #error>
                  <div class="image-slot">
                    <el-icon><Picture /></el-icon>
                  </div>
                </template>
              </el-image>
            </div>
            <div class="personPanel--info">
              <div class="personPanel--info__date">{{item.time || '--'}}</div>
              <div class="personPanel--info__addr one-line">{{item.address || '--'}}</div>
            </div>
          </div>
        </div>
      </el-scrollbar>
    </div>
    <div v-else class="empty" style="margin-top: 25%;">
      <DataEmptyTwo></DataEmptyTwo>
    </div>
  </ArmyPanelLayout>
</template>

<script>
import ArmyPanelLayout from '@/views/armyScreen/comp/ArmyPanelLayout.vue'
import {random14} from '@/util/utils.js'
import {ElScrollbar} from 'element-plus'
import {strangerRecordService} from '@/api/armyScreenApi.js'
import useCommonMethods from '@/mixin/useCommonMethods.js'
import DataEmptyTwo from "@/components/common/DataEmptyTwo.vue";
import $bus from "@/util/bus";
import BtnGroupDevideTab from "@/views/armyScreen/comp/BtnGroupDevideTab.vue";

export default {
  inject: ['screenContext'],
  components: {
    BtnGroupDevideTab,
    DataEmptyTwo,
    ArmyPanelLayout,
  },
  data() {
    return {
      tabList: [
        {
          "dictCode": 1,
          "dictValue": "内部人员",
          "sort": 1,
          "value": 1,
          "label": "内部人员"
        },
        {
          "dictCode": 2,
          "dictValue": "外部人员",
          "sort": 2,
          "value": 2,
          "label": "外部人员"
        }
      ],
      tabActive: '',
      total: 0,
      tableData: []
    }
  },
  setup() {
    const {dictByTypeService} = useCommonMethods()
    return {
      dictByTypeService
    }
  },
  async mounted() {
    $bus.on('reRequest', this.getStrangerRecord)
    this.getStrangerRecord()
  },
  beforeUnmount() {
    $bus.off('reRequest', this.getStrangerRecord)
  },
  methods: {
    typeChangeAction(value) {
      this.tabActive = value
      this.getStrangerRecord()
    },
    getStrangerRecord() {
      const paramObj = {}
      strangerRecordService(paramObj).then(res => {
        this.tableData = res?.data?.list || []
        this.total = res?.data?.total || 0
      })
    },
  }
}
</script>

<style lang="scss" scoped>
.StrangerComp {
  width: 439px;
  height: 100%;

  &--subtitle {
    width: 200px;
    line-height: 24px;
    margin-top: 10px;

    text-align: right;
    height: 20px;
    opacity: 0.7;
    font-family: PingFangSC-Regular;
    font-size: 14px;
    color: #DBECFB;
    letter-spacing: 0;
    font-weight: 400;
  }

  &--list{
    .personPanelList{
      //height: 100%;
      //animation: move 20s linear infinite normal;
      display: flex;
      flex-wrap: wrap;
      overflow-x: hidden;
      &:hover{
        animation-play-state:paused;
      }
    }
    .personPanel{
      width: 412px;
      height: 64px;
      background: rgba(21,77,160,0.20);
      display: flex;
      padding: 8px;
      margin: 0 auto;
      margin-bottom: 8px;
      &--img{
        width: 84px;
        min-width: 84px;
        height: 48px;
        margin-right: 12px;
        ::v-deep(.el-image){
          img {
            //width: 100%;
            max-height: 48px;
            height: auto;
            object-fit: contain !important;
          }
        }
        img{
          width: 100%;
          max-height: 48px;
        }
      }
      &--info{
        flex: 1;
        line-height: 24px;
        font-family: PingFangSC-Regular;
        font-size: 12px;
        color: #D8F0FF;
        letter-spacing: 0;
        font-weight: 400;
        &__date{
          width: 300px;
          &::before{
            display: inline-block;
            content: '';
            width: 16px;
            height: 16px;
            margin-right: 2px;
            position: relative;
            top: 2px;
            background-image: url("@/assets/images/armyScreen/门禁记录_时间@2x.png");
            background-size: cover;
          }

        }
        &__addr{
          width: 300px;
          &::before{
            display: inline-block;
            content: '';
            width: 16px;
            height: 16px;
            margin-right: 2px;
            position: relative;
            top: 2px;
            background-image: url("@/assets/images/armyScreen/门禁记录_地址@2x.png");
            background-size: cover;
          }
        }
      }
    }
  }
  @keyframes move {
    0% {
      transform: translateY(0);
    }
    100% {
      transform: translateY(calc(-100% + 330px));
    }

  }

}

.image-slot {
  margin-left: -4px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  //background: var(--el-fill-color-light);
  color: var(--el-text-color-secondary);
  font-size: 30px;
}
.image-slot .el-icon {
  font-size: 30px;
}
</style>
